package com.sz.demo.strategy;

import com.sz.demo.constant.PromotionEnum;
import com.sz.demo.discount.PercentageDiscount;
import com.sz.demo.entity.Strawberry;
import com.sz.demo.model.Fruit;
import com.sz.demo.promotion.FullReductionPromotion;
import com.sz.demo.promotion.NoPromotion;

import java.math.BigDecimal;
import java.util.*;

/**
 * 定价策略工厂
 * @author Lenovo
 */
public class PricingStrategyFactory {
    public static PricingStrategy getStrategy(String customerType) {
        switch (customerType.toUpperCase()) {
            case "A": 
            case "B": 
                return new RegularPricingStrategy();
            case "C":
                // 创建折扣配置
                List<Map.Entry<Class<? extends Fruit>, PercentageDiscount>> discounts = new ArrayList<>();
                discounts.add(new AbstractMap.SimpleEntry<>(Strawberry.class, new PercentageDiscount(new BigDecimal(0.8))));
                return new FruitDiscountWithPromotionPricingStrategy(discounts, new NoPromotion());
            case "D":
                List<Map.Entry<Class<? extends Fruit>, PercentageDiscount>> discountD = new ArrayList<>();
                discountD.add(new AbstractMap.SimpleEntry<>(Strawberry.class, new PercentageDiscount(new BigDecimal(0.8))));
                return new FruitDiscountWithPromotionPricingStrategy(discountD, new FullReductionPromotion(PromotionEnum.FULL_100_REDUCE_10));
            default: 
                throw new IllegalArgumentException("未知顾客类型: " + customerType);
        }
    }
}
